//
//  ICMProxyBasicInfoModel.m
//  ICrEAM
//
//  Created by kuroro on 16/11/22.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMProxyBasicInfoModel.h"

@implementation ICMProxyBasicInfoModel

#pragma mark 根据页面的值生成model数据
- (void)setupBasicInfoModelWithBasicInfoView:(ICMProxyBasicInfoView *)basicInfoView WithProxyOrderInfoView:(ICMProxyOrderInfoView *)orderView WithICMProxyMaintenanceAndPartsView:(ICMProxyMaintenanceAndPartsView *)mpView
{
    //会员信息
    if(![ICrEAMTool isVW])
    {
        self.DX_MEMBER_NO = basicInfoView.VWCardView.contentText;
    }
    else
    {
        self.HQ_VW_CARD_ID = basicInfoView.VWCardView.contentText;
    }
    self.IN_MILEAGE=basicInfoView.currentMileageView.contentText;
//    self.LAST_MILEAGE = basicInfoView.currentMileageView.contentText;
    self.DELIVERER = basicInfoView.customerNameView.contentText;
    self.DELIVERER_MOBILE = basicInfoView.customerPhoneNumberView.contentText;
    self.NEXT_MAINTAIN_DATE=basicInfoView.stepInTimeView.contentText;
    self.NEXT_MAINTAIN_MILEAGE=basicInfoView.nextMaintainMileage.contentText;
    
    self.END_TIME_SUPPOSED =orderView.predictFinishTimeView.contentText;
    self.OLD_PART_PROCESS_DESC = orderView.oldItemHandleView.contentText;
    self.OLD_PART_PROCESS = [ICrEAMTool getDeatilCodeWithParameterDesc:orderView.oldItemHandleView.contentText withCode:ICMEnumIntToString(ICMEnumOldPartProcessePre)];
    self.VOUCHER_TYPE_DESC = orderView.proofTypeView.contentText;
    self.VOUCHER_TYPE = [ICrEAMTool getDeatilCodeWithParameterDesc:orderView.proofTypeView.contentText withCode:ICMEnumIntToString(ICMEnumVoucherTypePre)];
    self.CHECK_CODE =orderView.checkCodeView.contentText;
    self.IS_EWS_SUCCESS_DESC = orderView.workshopIdentifierView.contentText;
    //车间标识
    self.IS_WORKSHOP = [ICrEAMTool getDeatilCodeWithParameterDesc:orderView.workshopIdentifierView.contentText withCode:ICMEnumIntToString(ICMEnumYESOrNOPre)];
    self.RO_REPAIR_TYPE_NAME = [orderView.repairTypeView.contentText stringByReplacingOccurrencesOfString:@"," withString:@";" options:NSCaseInsensitiveSearch range:NSMakeRange(0, orderView.repairTypeView.contentText.length)]?:@"";
    NSString *repair_type_string = orderView.repairTypeView.contentText?:@"";
    self.REPAIR_TYPE_CODE = @"";
    NSMutableArray *type_codes = [NSMutableArray array];
    if (![repair_type_string isEqualToString:@""]) {
        NSArray *repair_type_strings = [repair_type_string componentsSeparatedByString:@","];
        for (NSString *type in repair_type_strings) {
            NSString *code = [ICrEAMTool getRepiarTypeCodeWithRepiarName:type];
            [type_codes addObject:code];
        }
        self.REPAIR_TYPE_CODE = [type_codes componentsJoinedByString:@";"];
    }
//    if ([self.CAN_EDIT_WORKSHOP isEqualToString:@"12781001"]) {
//        self.IS_WORKSHOP=self.IS_EWS_SUCCESS;
//    }
    self.HONEST_BUSINESS_DESC = orderView.honestOperationsView.contentText;
    self.HONEST_BUSINESS = [ICrEAMTool getDeatilCodeWithParameterDesc:orderView.honestOperationsView.contentText withCode:ICMEnumIntToString(ICMEnumHonestBusinessPre)];
    //self.CUSTOMER_DESC = orderView.breakdownDescriptionView.contentText;
    self.RO_TROUBLE_DESC = orderView.breakdownDescriptionView.contentText;
    self.PRE_JUDGE = orderView.prejudgeView.contentText;
    //self.RO_TROUBLE_DESC = orderView.breakdownCheckReportView.contentText;
    self.CHECK_RESULT = orderView.breakdownCheckReportView.contentText;
    self.REMARK = orderView.remarksView.contentText;
    self.RECEPTION_DATE = orderView.getCarTimeView.contentText;
    self.RO_CREATE_DATE = orderView.startOrderTimeView.contentText;
    //工时单价
    if(mpView.workingUnitPriceView.contentText && ![mpView.workingUnitPriceView.contentText isEqualToString:@""])
    {
        self.LABOUR_PRICE = mpView.workingUnitPriceView.contentText;
    }
    else
    {
        self.LABOUR_PRICE = @"0";
    }
    //折前工时费
    if(mpView.workingPriceView.contentText && ![mpView.workingPriceView.contentText isEqualToString:@""])
    {
        self.LABOUR_TOTAL_AMOUNT = mpView.workingPriceView.contentText;
        self.LABOUR_AMOUNT = mpView.workingPriceView.contentText;
    }
    else
    {   self.LABOUR_AMOUNT = @"0";
        self.LABOUR_TOTAL_AMOUNT = @"0";
    }
    //折前材料费
    if(mpView.partsPriceView.contentText && ![mpView.partsPriceView.contentText isEqualToString:@""])
    {
        self.PART_TOTAL_AMOUNT = mpView.partsPriceView.contentText;
        self.REPAIR_PART_AMOUNT = mpView.partsPriceView.contentText;
    }
    else
    {   self.REPAIR_PART_AMOUNT = @"0";
        self.PART_TOTAL_AMOUNT = @"0";
    }
    //折前总金额
    if(mpView.totalPriceView.contentText && ![mpView.totalPriceView.contentText isEqualToString:@""])
    {
        self.REPAIR_AMOUNT = mpView.totalPriceView.contentText;
        
    }
    else
    {
        self.REPAIR_AMOUNT = @"0";
    }
    //工时折扣率
    if(mpView.workingRatioView.contentText && ![mpView.workingRatioView.contentText isEqualToString:@""])
    {
        self.LABOUR_RATE = mpView.workingRatioView.contentText;
    }
    else
    {
        self.LABOUR_RATE = @"1";
    }
    //零件折扣率
    if(mpView.partsRatioView.contentText && ![mpView.partsRatioView.contentText isEqualToString:@""])
    {
        self.PART_RATE = mpView.partsRatioView.contentText;
    }
    else
    {
        self.PART_RATE = @"1";
    }
    //折后总金额
    if(mpView.discountedPrice.contentText && ![mpView.discountedPrice.contentText isEqualToString:@""])
    {
        self.REAL_TOTAL_AMOUNT = mpView.discountedPrice.contentText;
    }
    else
    {
        self.REAL_TOTAL_AMOUNT = @"0";
    }
    
}


@end
